<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	template="/templates/template.xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:nu="http://nu.jcperera.homeip.net/facelets" xmlns:p="http://primefaces.org/ui">

	<ui:param name="title" value="NU Application New Scan Profile Page" />

	<f:metadata>
		<f:viewParam name="parentid" value="#{scanProfileBean.parentid}"></f:viewParam>
	</f:metadata>

	<ui:define name="body">
		<p:outputPanel>
			<p:messages id="edit-messages" autoUpdate="true" closable="true" showDetail="true" />

			<p:panel id="parent-panel" header="Parent Web Info Site" style="margin-bottom:10px;">
				<h:panelGrid columns="2">
					<h:outputLabel for="parent-entityid" value="ID: " />
					<p:inputText id="parent-entityid" value="#{scanProfileBean.site.entityid}" required="false" label="ID" size="45"
						readonly="true" disabled="true" />

					<h:outputLabel for="parent-url" value="URL: *" />
					<p:inputText id="parent-url" value="#{scanProfileBean.site.url}" required="true" label="URL" size="150"
						readonly="true" disabled="true" />

					<h:outputLabel for="parent-parameters" value="Parameters: *" />
					<p:inputText id="parent-parameters" value="#{scanProfileBean.site.parameters}" required="true" label="Parameters"
						size="100" readonly="true" disabled="true" />
				</h:panelGrid>
			</p:panel>

			<p:panel id="edit-panel" header="Create new Scan Profile" style="margin-bottom:10px;">
				<h:panelGrid columns="3" style="margin-bottom:10px;">
					<h:outputLabel for="entityid" value="ID: " />
					<p:inputText id="entityid" value="#{scanProfileBean.entityid}" required="false" label="ID" size="45"
						readonly="true" disabled="true" />
					<p:message for="entityid" />

					<h:outputLabel for="name" value="Name: " />
					<p:inputText id="name" value="#{scanProfileBean.name}" required="true" label="Name" size="100">
						<f:validateLength minimum="4" />
					</p:inputText>
					<p:message for="name" />

					<h:outputLabel for="periodicity" value="Periodicity: *" />
					<p:inputText id="periodicity" value="#{scanProfileBean.periodicity}" required="true" label="Periodicity" size="6">
						<f:validateLength minimum="1" />
					</p:inputText>
					<p:message for="periodicity" />

					<h:outputLabel for="periodicityUnit" value="Periodicity Unit: *" />
					<p:selectOneButton id="periodicityUnit" value="#{scanProfileBean.periodicityUnit}" required="true"
						label="Periodicity Unit">
						<f:selectItems value="#{scanProfileBean.periodicities}" var="periodicityUnit" itemValue="#{periodicityUnit}"
							itemLabel="#{text[periodicityUnit.value]}" />
					</p:selectOneButton>
					<p:message for="periodicityUnit" />

					<h:outputLabel for="howManyUp" value="How Many Up: *" />
					<p:inputText id="howManyUp" value="#{scanProfileBean.howManyUp}" required="true" label="howManyUp" size="6">
						<f:validateLength minimum="1" />
						<f:validateLongRange minimum="0" maximum="99999" />
					</p:inputText>
					<p:message for="howManyUp" />

					<h:outputLabel for="howManyDown" value="How Many Down: *" />
					<p:inputText id="howManyDown" value="#{scanProfileBean.howManyDown}" required="true" label="howManyDown" size="6">
						<f:validateLength minimum="1" />
						<f:validateLongRange minimum="0" maximum="99999" />
					</p:inputText>
					<p:message for="howManyDown" />
					
					<h:outputLabel for="fetchNextDelay" value="Fetch Next Delay: *" />
					<p:inputText id="fetchNextDelay" value="#{scanProfileBean.fetchNextDelay}" required="true" label="Fetch Next Delay"
						size="6">
						<f:validateLength minimum="1" />
					</p:inputText>
					<p:message for="fetchNextDelay" />

					<h:outputLabel for="fetchNextDelayUnit" value="Fetch Next Delay Unit: *" />
					<p:selectOneButton id="fetchNextDelayUnit" value="#{scanProfileBean.fetchNextDelayUnit}" required="true"
						label="Fetch Next Delay Unit">
						<f:selectItems value="#{scanProfileBean.periodicities}" var="fetchNextDelayUnit" itemValue="#{fetchNextDelayUnit}"
							itemLabel="#{text[fetchNextDelayUnit.value]}" />
					</p:selectOneButton>
					<p:message for="fetchNextDelayUnit" />
					
					<h:outputLabel for="tolerance" value="Tolerance: *" />
					<p:inputText id="tolerance" value="#{scanProfileBean.tolerance}" required="true" label="Tolerance" size="6">
						<f:validateLength minimum="1" />
					</p:inputText>
					<p:message for="tolerance" />

					<h:outputLabel for="toleranceUnit" value="Tolerance Unit: *" />
					<p:selectOneButton id="toleranceUnit" value="#{scanProfileBean.toleranceUnit}" required="true"
						label="Tolerance Unit">
						<f:selectItems value="#{scanProfileBean.periodicities}" var="toleranceUnit" itemValue="#{toleranceUnit}"
							itemLabel="#{text[toleranceUnit.value]}" />
					</p:selectOneButton>
					<p:message for="toleranceUnit" />
				</h:panelGrid>

				<p:commandButton value="Save" action="#{scanProfileBean.saveScanProfile}" id="saveButton" icon="ui-icon-disk"
					update="edit-panel,edit-messages"></p:commandButton>

				<p:button value="Go to parent" outcome="/pages/webinfosite/edit.xhtml?faces-redirect=true" process="@this">
					<f:param name="entityid" value="#{scanProfileBean.parentid}" />
				</p:button>
			</p:panel>
		</p:outputPanel>
	</ui:define>
</ui:composition>